package week7.example;
//---------------------------------------------------------------------------------------------------------
//  FoodItem.java    Author:Duanzhixuan
//
//  Represents an item of food. Used as the parent of a derived class to demonstrate indirect referencing.
//------------------------------------------------------------------------------------------------------------
public class FoodItem {
    final private int CALORIES_PER_GRAM = 9;
    private int fatGrams;
    protected int serving;
    //----------------------------------------------------------------------------------------------------------
    // Sets up this food item with the specified number of fat grams and number of servings.
    //-----------------------------------------------------------------------------------------------------------

    public  FoodItem(int numFatGrams,int numServings) {
        fatGrams = numFatGrams;
        serving = numServings;
    }

    //------------------------------------------------------------------------------------------------------------
    //  Computes and returns the number of calories in this food item due to fat.
    //---------------------------------------------------------------------------------------------------------------
    private int calories() {
        return fatGrams * CALORIES_PER_GRAM;
    }
    //------------------------------------------------------------------------------------------------------------
    //  Coputes and returns the number of fat calories per serving.
    //------------------------------------------------------------------------------------------------------------
    public int caloriesPerServing()
    {
        return (calories()/serving);
    }

}
